package game.snake;

import game.Point;
import game.snake.direction.Direction;

import java.io.Serializable;

/**
 * The body of the snake.
 * 
 * @author Sarun Wongtanakarn 5510546166
 * @author Apiwat Jierakulpanit 5510546212
 * @Version 2013.05.01
 */
public class SnakeBody implements Serializable {

	/** The direction of this SnakeBody. */
	private Direction direction;
	/** The Point of this SnakeBody. */
	private Point point;

	/**
	 * Creates a SnakeBody with giving Point and Direction
	 * 
	 * @param point
	 *            the point that reference to this SnakeBody
	 * @param direction
	 *            the direction for initialize
	 */
	public SnakeBody(Point point, Direction direction) {
		this.point = point;
		this.direction = direction;
	}

	/**
	 * Returns the direction of this SnakeBody.
	 * 
	 * @return the current direction
	 */
	public Direction getDirection() {
		return direction;
	}

	/**
	 * Sets the direction of this SnakeBody.
	 * 
	 * @param direction
	 *            the new direction for setting
	 */
	public void setDirection(Direction direction) {
		this.direction = direction;
	}

	/**
	 * Returns the point of this SnakeBody.
	 * 
	 * @return the current point
	 */
	public Point getPoint() {
		return point;
	}

	/**
	 * Sets the point of this SnakeBody.
	 * 
	 * @param point
	 *            the new point for setting
	 */
	public void setPoint(Point point) {
		this.point = point;
	}

	/**
	 * Returns the coordinate x-y of the current point in to String.
	 * @return the coordinate x-y 
	 */
	public String toString() {
		return String.format("(%d,%d)", point.X, point.Y);
	}
}
